package org.sdp.pearproject.service.impl;


import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;
import org.sdp.pearproject.dao.domain.*;
import org.sdp.pearproject.service.*;
import org.sdp.pearproject.service.custom.*;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

/**
 * @ClassName: EventsServiceImpl
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-27
 * @Version: 1.0
 * Table: pear_events
 * Comment:
 * 日程表
 */
@Service
public class EventsServiceImpl extends EventsServiceCustomImpl implements EventsService {

    static {
        beanClassNameMap.put("events", "eventsServiceImpl");
        listMethodNameMap.put("events", "listEvents");
        listMethodParameterClassNameMap.put("events", "EventsQueryRequest");
        updateMethodNameMap.put("events", "updateEvents");
        updateMethodParameterClassNameMap.put("events", "EventsUpdateRequest");
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer addEvents(EventsAddRequest request) throws Exception {
        super.fixRequest("events", "add", request);
        return super.addEvents(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer updateEvents(EventsUpdateRequest request) throws Exception {
        Events record = null;
        record = eventsMapper.selectByPrimaryKey(request.getId());
        super.fixRequest("events", "update", request, record);
        return super.updateEvents(request);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer deleteEvents(EventsDeleteRequest request) throws Exception {
        if (needCheckDeleteList(request)) {
            List<Events> list = null;
            EventsExample example = new EventsExample();
            example.createCriteria().andIdIn(request.getIdList());
            list = eventsMapper.selectByExample(example);
            fixRequest("events", "delete", request, list);
        } else {
            fixRequest("events", "delete", request);
        }
        return super.deleteEvents(request);
    }

    @Override
    public EventsQueryResponse queryEvents(EventsQueryRequest request) throws Exception {
        super.checkNonNull(request.getId(), "id");
        EventsQueryResponse result = super.queryEvents(request);
        checkResult("events", "query", request, result);
        return result;
    }

    @Override
    public List<EventsQueryResponse> listEvents(EventsQueryRequest request) throws Exception {
        List<EventsQueryResponse> list = super.listEvents(request);
        checkResult("events", "list", request, list);
        return list;
    }

    @Override
    public Integer countEvents(EventsQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("events", "count", request);
        return super.countEvents(request);
    }

    @Override
    public BaseStatResponse statEvents(EventsQueryRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("events", "stat", request);
        return super.statEvents(request);
    }

    @Override
    public List<EventsForEventsResponse> events(EventsForEventsRequest request) throws Exception {
        super.fixRequest("events", "events", request);
        List<EventsForEventsResponse> list = super.events(request);
        checkResult("events", "events", request, list);
        return list;
    }

    @Override
    public Integer countForEvents(EventsForEventsRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("events", "count_for_events", request);
        return super.countForEvents(request);
    }

    @Override
    public BaseStatResponse statForEvents(EventsForEventsRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("events", "stat_for_events", request);
        return super.statForEvents(request);
    }

    @Override
    public List<EventsForEventsMemberResponse> eventsMember(EventsForEventsMemberRequest request) throws Exception {
        super.fixRequest("events", "events_member", request);
        List<EventsForEventsMemberResponse> list = super.eventsMember(request);
        checkResult("events", "events_member", request, list);
        return list;
    }

    @Override
    public Integer countForEventsMember(EventsForEventsMemberRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("events", "count_for_events_member", request);
        return super.countForEventsMember(request);
    }

    @Override
    public BaseStatResponse statForEventsMember(EventsForEventsMemberRequest request) throws Exception {
        clearPageInfo(request);
        super.fixRequest("events", "stat_for_events_member", request);
        return super.statForEventsMember(request);
    }

}
